/********************************************************************
 * PROJECT: CSAIR ROST PROJECT.
 * SUPPLIER: FOREVER OPEN SOURCE SOFTWARE INC.
 ********************************************************************
 * FILE: GanttGridTask.java
 * (C) Copyright Foliage Team 2013, All Rights Reserved.
 ********************************************************************/
package org.foliage.rcp.ui.custom;

import java.util.Calendar;

import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.Item;
import org.foliage.rcp.ui.preference.GanttTaskSkin;
import org.foliage.rcp.ui.widgets.GanttTask;

/**
 * 带有报表功能的甘特图任务控件。
 * <ul>
 * <li>桥接解耦甘特图任务控件。</li>
 * </ul>
 * 
 * @author deathknight0718@gmail.com
 * @version 1.0.0
 */
public class GanttGridTask extends Item {

	// ----------------------------------------------- 

	public static final String DATA_KEY = GanttGridTask.class.getName();

	// ----------------------------------------------- 

	private final GanttTask task;

	// ----------------------------------------------- 

	public GanttGridTask(GanttGridItem item) {
		this(item, null, null);
	}

	public GanttGridTask(GanttGridItem item, Calendar lowerLimit, Calendar upperLimit) {
		super(item, SWT.NONE);
		this.task = new GanttTask(item.getGanttItem(), lowerLimit, upperLimit);
		this.task.setData(DATA_KEY, this);
	}

	public GanttGridTask(GanttGridItem item, GanttGridTaskData data) {
		super(item, SWT.NONE);
		this.task = new GanttTask(item.getGanttItem(), data.getLowerCalendar(), data.getUpperCalendar());
		this.task.setData(data.getData());
		this.task.setSkin(data.getSkin());
		this.task.setText(data.getText());
		this.task.setImage(data.getImage());
		this.task.setData(DATA_KEY, this);
	}

	// ----------------------------------------------- 

	@Override
	public String getText() {
		return task.getText();
	}

	@Override
	public void setText(String text) {
		task.setText(text);
	}

	@Override
	public Image getImage() {
		return task.getImage();
	}

	@Override
	public void setImage(Image image) {
		task.setImage(image);
	}

	public Rectangle getBounds() {
		return task.getBounds();
	}

	public void setBounds(Rectangle bounds) {
		task.setBounds(bounds);
	}

	public Calendar getLowerCalendar() {
		return task.getLowerCalendar();
	}

	public void setLowerCalendar(Calendar lowerCalendar) {
		task.setLowerCalendar(lowerCalendar);
	}

	public Calendar getUpperCalendar() {
		return task.getUpperCalendar();
	}

	public void setUpperCalendar(Calendar upperCalendar) {
		task.setUpperCalendar(upperCalendar);
	}

	public GanttTaskSkin getSkin() {
		return task.getSkin();
	}

	public void setSkin(GanttTaskSkin skin) {
		task.setSkin(skin);
	}

	@Override
	public Object getData() {
		return task.getData();
	}

	@Override
	public void setData(Object data) {
		task.setData(data);
	}

}
